﻿namespace ACCOUNTING
{
    using ACCOUNTING.LVY.Business;
    using ACCOUNTING.My.Resources;
    using C1.Win.C1FlexGrid;
    using C1.Win.C1FlexGrid.Util.BaseControls;
    using Microsoft.VisualBasic;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms;

    [DesignerGenerated]
    public class Frm_TranferData : Form
    {
        private static List<WeakReference> __ENCList = new List<WeakReference>();
        [AccessedThroughProperty("CboChiNhanh")]
        private ComboBox _CboChiNhanh;
        [AccessedThroughProperty("CmdCancel")]
        private Button _CmdCancel;
        [AccessedThroughProperty("CmdOK")]
        private Button _CmdOK;
        [AccessedThroughProperty("Label1")]
        private Label _Label1;
        [AccessedThroughProperty("VSList")]
        private C1.Win.C1FlexGrid.C1FlexGrid _VSList;
        private IContainer components;
        private bool mAllowAdd;
        private bool mAllowDel;
        private bool mAllowEdit;
        private bool mAllowView;
        private clsDataChiNhanh objCN;

        public Frm_TranferData()
        {
            base.Load += new EventHandler(this.Frm_ChuyenDuLieuDanhMucSangChiNhanh_Load);
            List<WeakReference> list = __ENCList;
            lock (list)
            {
                __ENCList.Add(new WeakReference(this));
            }
            this.mAllowView = false;
            this.mAllowDel = false;
            this.mAllowEdit = false;
            this.objCN = new clsDataChiNhanh();
            this.InitializeComponent();
        }

        public void BuildComboClient()
        {
            DataTable table = this.objCN.ShowList();
            this.CboChiNhanh.DataSource = table;
            this.CboChiNhanh.DisplayMember = "Ten";
            this.CboChiNhanh.ValueMember = "Ma";
            this.CboChiNhanh.SelectedIndex = 0;
        }

        private void CmdCancel_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void CmdOK_Click(object sender, EventArgs e)
        {
            if (LVYModule.ReturnIfNull(RuntimeHelpers.GetObjectValue(this.CboChiNhanh.SelectedValue), "", modGeneral.TypeOfValue.String).ToString().Trim() == "")
            {
                LVYModule.ShowWarning(modGeneral.Tranlated("Bạn phải chọn chi nh\x00e1nh!", ""));
                this.CboChiNhanh.Focus();
            }
            else
            {
                int num2 = this.VSList.Rows.Count - 1;
                for (int i = 1; i <= num2; i++)
                {
                    if (Conversion.Val(RuntimeHelpers.GetObjectValue(this.VSList[i, 1])) != 0.0)
                    {
                        SQLBulkModules.TranferDanhMuc(Conversions.ToString(this.VSList[i, 0]), "");
                    }
                }
                LVYModule.ShowWarning(modGeneral.Tranlated("Nghiệp vụ ho\x00e0n tất!", ""));
            }
        }

        [DebuggerNonUserCode]
        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        public void FillDanhMuc()
        {
            C1.Win.C1FlexGrid.C1FlexGrid vSList = this.VSList;
            vSList[1, 0] = "DM_NganhHang";
            vSList[1, 2] = "Danh mục ng\x00e0nh h\x00e0ng";
            vSList[2, 0] = "DM_NhomHangHoa";
            vSList[2, 2] = "Danh mục nh\x00f3m h\x00e0ng h\x00f3a";
            vSList[3, 0] = "DM_HangHoa";
            vSList[3, 2] = "Danh mục h\x00e0ng h\x00f3a";
            vSList[4, 0] = "DM_DonViTinh";
            vSList[4, 2] = "Danh mục đơn vị t\x00ednh";
            vSList[5, 0] = "DM_LoaiGia";
            vSList[5, 2] = "Danh mục loại gi\x00e1";
            vSList[6, 0] = "BH_GiaBan";
            vSList[6, 2] = "Gi\x00e1 b\x00e1n";
            vSList[7, 0] = "DM_DoiTuong";
            vSList[7, 2] = "Danh mục Kh\x00e1ch h\x00e0ng";
            vSList = null;
        }

        private void Frm_ChuyenDuLieuDanhMucSangChiNhanh_Load(object sender, EventArgs e)
        {
            LVYModule.GetUserRight(ref this.mAllowView, ref this.mAllowDel, ref this.mAllowEdit, ref this.mAllowAdd, Conversions.ToString(this.Tag), modGeneral.H_USERNAME);
            if (!this.mAllowView)
            {
                LVYModule.ShowWarning(modGeneral.Tranlated("Bạn kh\x00f4ng c\x00f3 quyền xem, li\x00ean hệ với người quản trị để biết th\x00eam chi tiết.", ""));
                this.Dispose();
            }
            else
            {
                this.FillDanhMuc();
                this.BuildComboClient();
            }
        }

        [DebuggerStepThrough]
        private void InitializeComponent()
        {
            ComponentResourceManager manager = new ComponentResourceManager(typeof(Frm_TranferData));
            this.VSList = new C1.Win.C1FlexGrid.C1FlexGrid();
            this.Label1 = new Label();
            this.CboChiNhanh = new ComboBox();
            this.CmdCancel = new Button();
            this.CmdOK = new Button();
            this.VSList.BeginInit();
            this.SuspendLayout();
            this.VSList.BorderStyle = C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.Light3D;
            this.VSList.ColumnInfo = manager.GetString("VSList.ColumnInfo");
            this.VSList.ExtendLastCol = true;
            this.VSList.KeyActionEnter = KeyActionEnum.MoveAcross;
            Point point = new Point(9, 0x26);
            this.VSList.Location = point;
            Padding padding = new Padding(0);
            this.VSList.Margin = padding;
            this.VSList.Name = "VSList";
            this.VSList.Rows.Count = 10;
            this.VSList.Rows.DefaultSize = 0x11;
            Size size = new Size(0x17b, 0xad);
            this.VSList.Size = size;
            this.VSList.StyleInfo = manager.GetString("VSList.StyleInfo");
            this.VSList.TabIndex = 0x18;
            this.VSList.Tag = "BH-0000";
            this.VSList.VisualStyle = VisualStyle.Office2007Blue;
            this.Label1.AutoSize = true;
            this.Label1.BackColor = Color.Transparent;
            point = new Point(0x18, 11);
            this.Label1.Location = point;
            this.Label1.Name = "Label1";
            size = new Size(0x37, 13);
            this.Label1.Size = size;
            this.Label1.TabIndex = 0x17;
            this.Label1.Text = "Chi nh\x00e1nh";
            this.CboChiNhanh.FormattingEnabled = true;
            point = new Point(0x62, 7);
            this.CboChiNhanh.Location = point;
            this.CboChiNhanh.Name = "CboChiNhanh";
            size = new Size(0x112, 0x15);
            this.CboChiNhanh.Size = size;
            this.CboChiNhanh.TabIndex = 0x16;
            this.CmdCancel.DialogResult = DialogResult.Cancel;
            this.CmdCancel.Image = ACCOUNTING.My.Resources.Resources.Closed;
            this.CmdCancel.ImageAlign = ContentAlignment.MiddleLeft;
            point = new Point(0x13a, 0xd6);
            this.CmdCancel.Location = point;
            this.CmdCancel.Name = "CmdCancel";
            size = new Size(0x49, 0x18);
            this.CmdCancel.Size = size;
            this.CmdCancel.TabIndex = 0x15;
            this.CmdCancel.Text = "Th&o\x00e1t";
            this.CmdCancel.UseVisualStyleBackColor = true;
            this.CmdOK.Image = ACCOUNTING.My.Resources.Resources.Selected;
            this.CmdOK.ImageAlign = ContentAlignment.MiddleLeft;
            point = new Point(0xe8, 0xd6);
            this.CmdOK.Location = point;
            this.CmdOK.Name = "CmdOK";
            size = new Size(0x4d, 0x18);
            this.CmdOK.Size = size;
            this.CmdOK.TabIndex = 20;
            this.CmdOK.Text = "&Chọn";
            this.CmdOK.UseVisualStyleBackColor = true;
            SizeF ef = new SizeF(6f, 13f);
            this.AutoScaleDimensions = ef;
            this.AutoScaleMode = AutoScaleMode.Font;
            this.BackgroundImage = ACCOUNTING.My.Resources.Resources.background;
            size = new Size(0x189, 0xf5);
            this.ClientSize = size;
            this.ControlBox = false;
            this.Controls.Add(this.VSList);
            this.Controls.Add(this.Label1);
            this.Controls.Add(this.CboChiNhanh);
            this.Controls.Add(this.CmdCancel);
            this.Controls.Add(this.CmdOK);
            this.Name = "Frm_TranferData";
            this.StartPosition = FormStartPosition.CenterScreen;
            this.Tag = "BH-0014";
            this.Text = "CHUYEN DU LIEU";
            this.VSList.EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();
        }

        public bool TransferData(string strKhoaDoiTuong, string strTableName)
        {
            bool flag=false;
            this.Cursor = Cursors.WaitCursor;
            IDataParameter[] commandParameters = new IDataParameter[2];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@KhoaDoiTuong", DbType.Int64, ParameterDirection.Input, strKhoaDoiTuong);
                commandParameters[1] = DBHelper.createParameter("@TableName", DbType.Int64, ParameterDirection.Input, strTableName);
                DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "HT_TransferDataToClient", commandParameters);
                this.Cursor = Cursors.Default;
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                this.Cursor = Cursors.Default;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        private void VSList_BeforeEdit(object sender, RowColEventArgs e)
        {
            if (LVYModule.ReturnIfNull(RuntimeHelpers.GetObjectValue(this.VSList[e.Row, 0]), "", modGeneral.TypeOfValue.Nothing).ToString().Trim() == "")
            {
                e.Cancel = true;
            }
            else if (e.Col == 2)
            {
                e.Cancel = true;
            }
        }

        internal virtual ComboBox CboChiNhanh
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CboChiNhanh;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._CboChiNhanh = value;
            }
        }

        internal virtual Button CmdCancel
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdCancel;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CmdCancel_Click);
                if (this._CmdCancel != null)
                {
                    this._CmdCancel.Click -= handler;
                }
                this._CmdCancel = value;
                if (this._CmdCancel != null)
                {
                    this._CmdCancel.Click += handler;
                }
            }
        }

        internal virtual Button CmdOK
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdOK;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CmdOK_Click);
                if (this._CmdOK != null)
                {
                    this._CmdOK.Click -= handler;
                }
                this._CmdOK = value;
                if (this._CmdOK != null)
                {
                    this._CmdOK.Click += handler;
                }
            }
        }

        internal virtual Label Label1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label1 = value;
            }
        }

        internal virtual C1.Win.C1FlexGrid.C1FlexGrid VSList
        {
            [DebuggerNonUserCode]
            get
            {
                return this._VSList;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                RowColEventHandler handler = new RowColEventHandler(this.VSList_BeforeEdit);
                if (this._VSList != null)
                {
                    this._VSList.BeforeEdit -= handler;
                }
                this._VSList = value;
                if (this._VSList != null)
                {
                    this._VSList.BeforeEdit += handler;
                }
            }
        }
    }
}

